home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12500 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  79 lines

  1. Path: news.dal.ca!news
  2. From: Klaus.Eichele@Dal.Ca (Klaus Eichele)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: FLOATING POINT PROBLEM
  5. Date: Mon, 01 Apr 1996 16:55:36 GMT
  6. Organization: Dalhousie University
  7. Message-ID: <4jojoa$aa6@News.Dal.Ca>
  8. References: <4joeof$hoc@newsbf02.news.aol.com>
  9. NNTP-Posting-Host: rewasylishen.chem.dal.ca
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. maddawson@aol.com (MADDawson) wrote:
  13.  
  14. >I have been working on a Windows program.  The prog compiles correctly
  15. >without any warnings or errors.  When I add something that tries to get a
  16. >float value from a string, the program quits running.  It does this in and
  17. >out of the IDE.
  18.  
  19. >I have erased the project and copied a project from another program and I
  20. >get the same results.  I have re-created the project from scratch and
  21. >still no luck.
  22.  
  23. >I have included every .h file I would think would have something to do
  24. >with it.  I would REALLY appreciate some help with this as I have compiled
  25. >a similar program correctly and have not had this problem before.  I would
  26. >think it might be a compiler setting or something NOT in the program
  27. >itself.
  28.  
  29. >I have included the following lines.
  30.  
  31. >float part_number;
  32. >char buffer[100];
  33.  
  34. >I get the value of the edit control using GetDlgItemText and put into
  35. >buffer.  (This works as I have a MessageBox that shows the value.
  36.  
  37. >Then I try:
  38.  
  39. >part_number = atof(buffer);
  40.  
  41. >This is where the prog stops.
  42.  
  43. >I have also tried:
  44.  
  45. >sscanf(buffer, "%f", &part_number);
  46.  
  47. >It stops here, too.  (I have used this line in another prog and it works
  48. >correctly.
  49.  
  50. >Again, I would really appreciate any help I receive on this.
  51.  
  52. Hi, 
  53. you didn't specify which compiler you are using. If you are using a
  54. version of Borland's C++ compilers, my first guess would be a
  55. "floating point format not linked error". From the Borland README.TXT
  56. file:
  57.  
  58. ===========================================================
  59.   2.  CAUSE:  Either the compiler is over-optimizing, or the
  60.       floating-point formats really do need to be linked in because
  61.       your program manipulates floats in a limited and specific
  62.       fashion. Under certain obscure conditions, the compiler will
  63.       ignore floating point usage in scanf() (e.g., trying to
  64.       read into a float variable that is part of an array contained
  65.       in a structure.)
  66.  
  67.       FIX: Add the following to one source module:
  68.  
  69.            extern _floatconvert;
  70.            #pragma extref _floatconvert
  71.  
  72. ==============================================================
  73. Good Luck,
  74. Klaus
  75. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  76. Klaus Eichele         keichele@is.dal.ca  
  77. http://is.dal.ca/~keichele/keichele.html
  78.  
  79.